/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package UnitTest;

import junit.framework.TestCase;
import DB.DBManager;
import DB.Controle.ControllerControle;
import DB.Usuario.ControllerUsuario;
import Model.Usuario;
import java.sql.SQLException;
import static junit.framework.TestCase.assertEquals;

/**
 *
 * @author KZA
 */
public class TesteControle extends TestCase {
    
    DBManager db;
    
    public TesteControle(String testName, DBManager db) {
        super(testName);
        this.db = db;
    }

    public long testeInsertControleBanco(long userId) throws SQLException, ClassNotFoundException {
        System.out.println("* Unit_Test: I testeInsertControleBanco");
        
        Usuario user = new Usuario();
        ControllerUsuario uc = ControllerUsuario.getInstance();
        user = uc.getByID(userId);
        
        ControllerControle cc = ControllerControle.getInstance();
        int count = db.getTableCount("Controle");
        long id = cc.insert(user);

        assertEquals(count+1, db.getTableCount("Controle"));
        
        System.out.println("* Unit_Test: F testeInsertControleBanco");
        return id;
    }
}
